<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<script src="/html/axios.min.js"></script>
<script src="/html/util.js"></script>
<script>
    window.onload = function (){
        findByItem(1)
    }
    var id = getQuery("id");

    function findByItem(pageNO){
        axios.get("/topic/findByItem",{
            params:{
                channelId:id,
                pageNO:pageNO,
                name:$('topicName').value,
                userName:$('userName').value,
                startDate:$('startDate').value,
                endDate:$('endDate').value
            }
        }).then(e => {
            var infoObj = e.data;
            var str = "";
            for (var i=0;i<infoObj.list.length;i++){
                var obj = infoObj.list[i];
                str += `<tr><td><a href="/html/push/res.html?id=${obj.id}">${obj.name}</a></td><td>${obj.user.code}</td>
                        <td>${obj.count}</td><td>${obj.deliverDate}</td></tr>`
            }
            $('topicData').innerHTML = str;

            var pageStr = "";
            for (var i=1;i<=infoObj.pages;i++){
                pageStr += `<a href="javascript:findByItem(${i})" style="margin-left: 10px">${i}</a>`
            }
            $('cutDiv').innerHTML = pageStr;
        })
    }

    function addTopic(){
        location.href="/html/push/addTopic.html?id="+id;
    }
</script>
<body>
    主贴名称:<input type="text" id="topicName">
    作者:<input type="text" id="userName"><br>
    起始日期:<input type="date" id="startDate">
    结束日期:<input type="date" id="endDate"><br>
    <input type="button" value="查询" onclick="findByItem(1)"><br>
    <input type="button" value="发表话题" onclick="addTopic()"><br>
    <table border="1" cellspacing="0" width="60%">
        <thead>
            <tr><th>主题</th><th>作者</th><th>回贴数量</th><th>发帖时间</th></tr>
        </thead>
        <tbody id="topicData"></tbody>
    </table>
    <div id="cutDiv"></div>
</body>
</html>